<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<title>密码修改</title>
		<script type="text/javascript" src="resource/jquery/jquery-1.8.2.js"></script>
		<style type="text/css">
			html,body {
				height: 100%
			}	
			.message {
				width: 120px;
				font-size: 12px;
			}
		</style>
		{literal}
		<script type="text/javascript">

			//未知用途
			function closeDiv() {
				document.getElementById('fade').style.display = 'none';
				document.getElementById('popupDiv').style.display = 'none';
			}

			//检查输入是否合法
			function check() {
				//获取输入内容
				var oldPassword = $("#oldPassword").val();
				var newPassword = $("#newPassword").val();
				var passwordConfirm = $("#passwordConfirm").val();

				var info = "";

				if(oldPassword == ""){
					info = "请输入原密码\n";
				}else{
					//检查输入是否符合要求
					if(newPassword == "" || passwordConfirm == ""){
						info += "新密码不能为空\n";
					}else{
						if(newPassword != passwordConfirm){
							info += "两次输入的密码不相同\n";
						}else if(oldPassword == newPassword){
							info += "新旧密码不能相同";
						}
					}
				}

				return info;
			}

			$(document).ready(function(){
				
				//提交按钮click事件
				$("#submit").click(function(){
					//获取输入内容
					var oldPassword = $("#oldPassword").val();
					var newPassword = $("#newPassword").val();
					var passwordConfirm = $("#passwordConfirm").val();

					//验证输入
					var info = check();
					if(info == ""){
						//ajax操作
						$.post("libs\user_service.php?act=alterPwd", {"oldPassword":oldPassword, "newPassword":newPassword}, function(datas){
							if (datas == true) {
								alert("修改成功");
							} else {
								alert("原密码错误,修改失败");
							}
						});
					}else{
						alert(info);
					}


				});
			});
	</script>
	{/literal}
	</head>
	<body style="margin:0px 0px;font-size:18px;font-family:'微软雅黑';">
	<table width="100%" height="100%">
		<th colspan="3" style="font-size:24px;font-weight:bold;">密码修改</th>
		<tr><td align="right" width="40%">原密码：</td><td><input type="password" id="oldPassword"></td>
			<td class="message" align="left" id="opmsg"></td>
		</tr>
		<tr><td align="right">新密码：</td><td><input id="newPassword" type="password"></td>
			<td class="message" align="left"></td>
		</tr>
		<tr><td align="right">再输入：</td><td><input id="passwordConfirm" type="password"></td>
			<td class="message" align="left" id="msg"></td>
		</tr>
		<tr><td align="center" colspan="3"><input type="button" value="修改" id="submit"></td></tr>
	</table>
	</body>
</html>